/* 
 * Copyright (c) 2012, Fromentin Xavier, Schnell Michaël, Dervin Cyrielle, Brabant Quentin
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *      * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *      * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *      * The names of its contributors may not be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Fromentin Xavier, Schnell Michaël, Dervin Cyrielle OR Brabant Quentin 
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package gword.generateur;

import java.text.SimpleDateFormat;

/**
 * Utility interface containing constants and templates for the generation of a WordML 2003 document.
 * 
 * @author		Schnell Michaël
 * @version		1.0
 */
public interface WordConstants {
	
	/**
	 * Pattern used by the dates property fields in the word document.
	 */
	public static final String DATE_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'" ; //$NON-NLS-1$
	
	/**
	 * Used to format dates in the pattern needed for a Word document.
	 */
	public static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat(DATE_PATTERN) ;
	
	/**
	 * Template for the whole document.
	 * 
	 * <p>The following field has to be set: xml code of teh document.
	 */
	public static final String WORD_DOCUMENT = 
			"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + //$NON-NLS-1$
			"<?mso-application progid=\"Word.Document\"?>" + //$NON-NLS-1$
			"<w:wordDocument w:macrosPresent=\"yes\" w:embeddedObjPresent=\"no\" w:ocxPresent=\"no\" xml:space=\"preserve\" xmlns:aml=\"http://schemas.microsoft.com/aml/2001/core\" xmlns:dt=\"uuid:C2F41010-65B3-11d1-A29F-00AA00C14882\" xmlns:ve=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.microsoft.com/office/word/2003/wordml\" xmlns:wx=\"http://schemas.microsoft.com/office/word/2003/auxHint\" xmlns:wsp=\"http://schemas.microsoft.com/office/word/2003/wordml/sp2\" xmlns:sl=\"http://schemas.microsoft.com/schemaLibrary/2003/core\" xmlns:st1=\"urn:schemas-microsoft-com:office:smarttags\">%s</w:wordDocument>" ; //$NON-NLS-1$
	
	/**
	 * Template for the document properties (tag: {@code <o:DocumentProperties>}).
	 * 
	 * <p>The following fields have to be set (in that order):
	 * <ol>
	 * <li>title of the document
	 * <li>author of the document
	 * <li>last author of the document
	 * <li>date of creation (Example: 2012-04-30T16:35:00Z)
	 * <li>date of last save (Example: 2012-04-30T16:35:00Z)
	 * </ol>
	 */
	public static final String DOCUMENT_PROPERTIES = 
			"<o:DocumentProperties>" + //$NON-NLS-1$
				"<o:Title>%s</o:Title>" + //$NON-NLS-1$
				"<o:Author>%s</o:Author>" + //$NON-NLS-1$
				"<o:LastAuthor>%s</o:LastAuthor>" + //$NON-NLS-1$
				"<o:Created>%s</o:Created>" + //$NON-NLS-1$
				"<o:LastSaved>%s</o:LastSaved>" + //$NON-NLS-1$
			"</o:DocumentProperties>" ; //$NON-NLS-1$
	
	/**
	 * Template for the definition of the default font for the document.
	 * 
	 * <p>The default font is set to be {@code Time New Roman} for all languages.
	 */
	public static final String FONTS = 
			"<w:fonts>" + //$NON-NLS-1$
				"<w:defaultFonts w:ascii=\"Times New Roman\" w:fareast=\"Times New Roman\" w:h-ansi=\"Times New Roman\" w:cs=\"Times New Roman\"/>" + //$NON-NLS-1$
				"<w:font w:name=\"Times New Roman\">" + //$NON-NLS-1$
					"<w:panose-1 w:val=\"02020603050405020304\"/>" + //$NON-NLS-1$
					"<w:charset w:val=\"00\"/>" + //$NON-NLS-1$
					"<w:family w:val=\"Roman\"/>" + //$NON-NLS-1$
					"<w:pitch w:val=\"variable\"/>" + //$NON-NLS-1$
					"<w:sig w:usb-0=\"E0002AFF\" w:usb-1=\"C0007841\" w:usb-2=\"00000009\" w:usb-3=\"00000000\" w:csb-0=\"000001FF\" w:csb-1=\"00000000\"/>" + //$NON-NLS-1$
				"</w:font>" + //$NON-NLS-1$
			"</w:fonts>" ; //$NON-NLS-1$
	
	/**
	 * Template for the definition of the lists styles.
	 * 
	 * <p>The following field has to be set: xml list of list definition and lists. Example:
	 * <pre>{@code
	 *<w:listDef w:listDefId="0">
	 * ...
	 *</w:listDef>
	 * ...
	 *<w:list w:ilfo="1">
	 * <w:ilst w:val="5"/>
	 *</w:list>
	 *...
	 * }</pre>
	 */
	public static final String LISTS = "<w:lists>%s</w:lists>" ; //$NON-NLS-1$
	
	/**
	 * Template for the definition of the a list style.
	 * 
	 * <p>The following fields have to be set (in that order):
	 * <ol>
	 * <li>identifier of the list definition
	 * <li>definition of the levels
	 * </ol>
	 * Example of a list level definition:
	 * <pre>{@code
	 *<w:lvl w:ilvl="0">
	 *  <w:start w:val="1"/>
	 *  <w:lvlText w:val="%1."/>
	 *  <w:lvlJc w:val="left"/>
	 *  <w:pPr>
	 *    <w:tabs>
	 *      <w:tab w:val="list" w:pos="1080"/>
	 *    </w:tabs>
	 *    <w:ind w:left="1080" w:hanging="360"/>
	 *  </w:pPr>
	 *</w:lvl> 
	 * }</pre>
	 */
	public static final String LIST_DEFINITION = "<w:listDef w:listDefId=\"%s\">%s</w:listDef>" ; //$NON-NLS-1$
	
	/**
	 * Template for the level definition in a list definition.
	 * 
	 * <p>The following fields have to be set (in that order):
	 * <ol>
	 * <li>the level (0 is the first level, 1 the second, ...)
	 * <li>the start value for the numbering
	 * <li>the type of numbering (Example: 23 for bullet)
	 * <li>the format for the numbering (Example: '%1.' will give 
	 * 	   the following numbering - 1., 2., ...)
	 * <li>the justification of the actual number
	 * <li>the position of the tab for the list
	 * <li>the space between left margin and text
	 * <li>the hanging indent for all lines after first
	 * </ol>
	 */
	public static final String LIST_LEVEL_DEFINITION = 
			"<w:lvl w:ilvl=\"%s\">" + //$NON-NLS-1$
				"<w:start w:val=\"%s\"/>" + //$NON-NLS-1$
				"<w:nfc w:val=\"%s\"/>" + //$NON-NLS-1$
				"<w:lvlText w:val=\"%s\"/>" + //$NON-NLS-1$
				"<w:lvlJc w:val=\"%s\"/>" + //$NON-NLS-1$
				"<w:pPr>" + //$NON-NLS-1$
					"<w:tabs>" + //$NON-NLS-1$
					"<w:tab w:val=\"list\" w:pos=\"%s\"/>" + //$NON-NLS-1$
						"</w:tabs>" + //$NON-NLS-1$
					"<w:ind w:left=\"%s\" w:hanging=\"%s\"/>" + //$NON-NLS-1$
				"</w:pPr>" + //$NON-NLS-1$
			"</w:lvl>" ; //$NON-NLS-1$
	
	/**
	 * Template for the list style definition.
	 * 
	 * <p>The following fields have to be set (in that order):
	 * <ol>
	 * <li>the identifier of this list style
	 * <li>the identifier of the list definition this list is based on
	 * </ol>
	 */
	public static final String LIST_STYLE_DEFINITION = "<w:list w:ilfo=\"%s\"><w:ilst w:val=\"%s\"/></w:list>" ; //$NON-NLS-1$

	/**
	 * Template for the definition of the styles.
	 * 
	 * <p>The following field has to be set: xml list of style definitions. Example:
	 * <pre>{@code
	 *<w:style w:type="paragraph" w:default="on" w:styleId="Normal">
	 *  <w:name w:val="Normal"/>
	 *  <w:rsid w:val="00535F27"/>
	 *  <w:rPr>
	 *    <wx:font wx:val="Times New Roman"/>
	 *    <w:sz w:val="24"/>
	 *    <w:sz-cs w:val="24"/>
	 *    <w:lang w:val="EN-GB" w:fareast="EN-US" w:bidi="AR-SA"/>
	 *  </w:rPr>
	 *</w:style>
	 * }</pre>
	 */
	public static final String STYLES = "<w:styles>%s</w:styles>" ; //$NON-NLS-1$
	
	/**
	 * Template for a basic style definition.
	 * 
	 * <p>The following fields have to be set (in that order):
	 * <ol>
	 * <li>the type of style (paragraph, character, table or list)
	 * <li>whether this style is the default for this type of style (on or off)
	 * <li>the name used to refer to this style within this document
	 * <li>the primary name of style
	 * <li>the displayed name in the user interface
	 * <li>the font name used by this paragraph
	 * </ol>
	 */
	public static final String BASIC_STYLE_DEFINITION = 
			"<w:style w:type=\"%s\" w:default=\"%s\" w:styleId=\"%s\">" + //$NON-NLS-1$
				"<w:name w:val=\"%s\"/>" + //$NON-NLS-1$
				"<wx:uiName wx:val=\"%s\"/>" + //$NON-NLS-1$
				"<w:rPr>" + //$NON-NLS-1$
					"<wx:font wx:val=\"%s\"/>" + //$NON-NLS-1$
				"</w:rPr>" + //$NON-NLS-1$
			"</w:style>" ; //$NON-NLS-1$
	
	/**
	 * Template for a heading style definition.
	 * 
	 * <p>The following fields have to be set (in that order):
	 * <ol>
	 * <li>the name used to refer to this style within this document
	 * <li>the primary name of style
	 * <li>the displayed name in the user interface
	 * <li>the next style used after this one
	 * <li>the outline level (used for automatic numbering)
	 * <li>the font name used by this paragraph
	 * </ol>
	 */
	public static final String HEADING_STYLE_DEFINITION =
			"<w:style w:type=\"paragraph\" w:styleId=\"%s\">" + //$NON-NLS-1$
				"<w:name w:val=\"%s\"/>" + //$NON-NLS-1$
				"<wx:uiName wx:val=\"%s\"/>" + //$NON-NLS-1$
				"<w:next w:val=\"%s\"/>" + //$NON-NLS-1$
				"<w:pPr>" + //$NON-NLS-1$
					"<w:keepNext/>" + //$NON-NLS-1$
					"<w:outlineLvl w:val=\"%s\"/>" + //$NON-NLS-1$
				"</w:pPr>" + //$NON-NLS-1$
				"<w:rPr>" + //$NON-NLS-1$
					"<wx:font wx:val=\"%s\"/>" + //$NON-NLS-1$
				"</w:rPr>" + //$NON-NLS-1$
			"</w:style>" ; //$NON-NLS-1$
	
	/**
	 * Template for the definition of a "table" style.
	 */
	public static final String ARRAY_STYLE_DEFINITION =
			"<w:style w:styleId=\"TableStyle\" w:type=\"table\">" + //$NON-NLS-1$
				"<w:name w:val=\"TableStyle\"/>" + //$NON-NLS-1$
				"<w:hidden w:val=\"on\"/>" + //$NON-NLS-1$
				"<w:tblPr>" + //$NON-NLS-1$
					"<w:tblInd w:w=\"0\" w:type=\"auto\"/>" + //$NON-NLS-1$
					"<w:jc w:val=\"left\"/>" + //$NON-NLS-1$
				"</w:tblPr>" + //$NON-NLS-1$
			"</w:style>" ; //$NON-NLS-1$
	
	/**
	 * Template for the document properties (tag: {@code <w:docPr>}).
	 */
	public static final String WORD_DOCUMENT_PROPERTIES = 
			"<w:docPr>" + //$NON-NLS-1$
				"<w:view w:val=\"print\"/>" + //$NON-NLS-1$
				"<w:zoom w:percent=\"80\"/>" + //$NON-NLS-1$
				"<w:dontDisplayPageBoundaries/>" + //$NON-NLS-1$
				"<w:doNotEmbedSystemFonts/>" + //$NON-NLS-1$
				"<w:validateAgainstSchema/>" + //$NON-NLS-1$
				"<w:saveInvalidXML w:val=\"off\"/>" + //$NON-NLS-1$
				"<w:compat>" + //$NON-NLS-1$
					"<w:breakWrappedTables/>" + //$NON-NLS-1$
					"<w:snapToGridInCell/>" + //$NON-NLS-1$
					"<w:wrapTextWithPunct/>" + //$NON-NLS-1$
					"<w:useAsianBreakRules/>" + //$NON-NLS-1$
					"<w:useWord2002TableStyleRules/>" + //$NON-NLS-1$
				"</w:compat>" + //$NON-NLS-1$
			"</w:docPr>" ; //$NON-NLS-1$
	
	/**
	 * Template for the document body.
	 * 
	 * <p>The following field has to be set: xml list of the document content.
	 */
	public static final String DOCUMENT_BODY = "<w:body>%s</w:body>" ; //$NON-NLS-1$
	
}// interface WordConstants